﻿using d1Project.Modules.Common.doCache.Migrations;
using d1Project.Modules.Common.doCache.Models;
using d1Project.Tools;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace d1Project.Modules.Common.doCache
{
    public  class doCacheDbContext : DbContext
    {
        static doCacheDbContext()
        {
            Database.SetInitializer<doCacheDbContext>(new ApplicationDbInitializer());
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<doCacheDbContext, doCacheDbConfig>());
        }
        public doCacheDbContext()
            : base(DoEnvironment.DefaultDbName)
        {
            this.Configuration.LazyLoadingEnabled = false;
        }

        //-------------------------------------------------------------------------------
        public DbSet<DoCache> DoCaches { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.HasDefaultSchema("dbo");
        }

        public class ApplicationDbInitializer : CreateDatabaseIfNotExists<doCacheDbContext>
        {
            protected override void Seed(doCacheDbContext context)
            {
                base.Seed(context);                
            }
        }
        
    }
}